import request from './request'
import { API_CONFIG } from './config'

export const datasetApi = {
  /**
   * 上传数据集文件
   * @param {File[]} files - 要上传的文件列表
   * @returns {Promise} - 返回上传结果
   */
  uploadDataset(files) {
    const formData = new FormData()
    files.forEach(file => {
      formData.append('files', file)
    })

    return request({
      url: API_CONFIG.DATASET.UPLOAD,
      method: 'POST',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      // 上传进度处理
      onUploadProgress: progressEvent => {
        const percentCompleted = Math.round(
          (progressEvent.loaded * 100) / progressEvent.total
        )
        console.log('上传进度：', percentCompleted)
      }
    })
  }
} 